﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;


namespace MixScript.BLL.FI
{
    public class BeginingCurrency : cBaseBLL
    {
        public BeginingCurrency()
        { }

        public bool GetCurrency(out DataTable dt, string year, string month, string curr)
        {
            try
            {
                dt = new DataTable();
                string sSQL = @"SELECT  currency ,CAST([date] AS NVARCHAR(11)) as  date ,
                        rate , jual , beli  FROM accdailykurs WHERE month(date) = '{0}' and year(date) ='{1}' AND currency ='{2}'";
                dt = Dbserver.ExecuteQuery(string.Format(sSQL, month, year, curr), "BegginingCurrency");
                return dt.Rows.Count > 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
        public bool Save(string curr, string From, string To, string Rate, string Buy, string Sell)
        {

            string sSQL = @"Insert_MultipleCurrency '{0}','{1}','{2}','{3}','{4}','{5}'";
            try
            {
                return Dbserver.ExecuteNonQuery(string.Format(sSQL, curr, From, To, Rate, Buy, Sell));
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
        public bool Update(string curr, string date, string Rate, string Buy, string Sell)
        {
            string sSQL = @"UPDATE accdailykurs Set rate='{2}',jual='{3}',beli='{4}' where currency='{0}' and [date]='{1}'";
            try
            {
                return Dbserver.ExecuteNonQuery(string.Format(sSQL, curr, date, Rate, Buy, Sell));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public bool Delete(string curr, string date)
        {
            string sSQL = @"DELETE accdailykurs  where currency='{0}' and [date]='{1}'";
            try
            {
                return Dbserver.ExecuteNonQuery(string.Format(sSQL, curr, date));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    }
}
